﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using akmControl.DataAccess;

namespace akmControl
{
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace CustomControls
    {
        public class FirstControl : Control
        {
            private String message = "Hello";

            public virtual String Message
            {
                get
                {
                    return message;
                }
                set
                {
                    message = value;
                }
            }

            protected override void Render(HtmlTextWriter writer)
            {
                var sts = StudData.GetStuds();
                StringBuilder sb = new StringBuilder();

                sb.Append("<table>");
                sb.Append("<tr>");
                sb.Append("<td>Roll No.</td>");
                sb.Append("<td>Name</td>");
                sb.Append("</tr>");
                foreach (var studInfo in sts)
                {
                    sb.Append("<tr>");
                    sb.Append("<td>" + studInfo.Roll + "</td>");
                    sb.Append("<td>" + studInfo.Name + "</td>");
                    sb.Append("</tr>");
                }

                sb.Append("</table>");
                
                //writer.Write("<script>function show(){ alert('Hi custom control') }</script>"+"<font> "
                //            + this.Message + "<br>" + "The time on the server is " + System.DateTime.Now.ToLongTimeString()
                //            + "</font>"+"<input type=button value='Hi' onclick='show()'>");

                writer.Write(sb.ToString());
            }

        }
    }

}
